﻿layui.use(['table', 'dropdown', 'layer', 'form'], function () {
    var table = layui.table;
    var dropdown = layui.dropdown;
    var layer = layui.layer;
    var form = layui.form;
    var laypage = layui.laypage;
    //反填显示复检信息
    //反填

    $(function () {
       
        fantian3();//复检信息
    })

    //反填复检信息
    function fantian3() {
        // 发送AJAX请求获取数据
        console.log(localStorage.getItem("reinspectionId"))
        $.ajax({
            type: "get",
            url: "/Quality/GetByidRein",
            data: {
                ReinspectionId: localStorage.getItem("reinspectionId"),
                token: localStorage.getItem("token")
            },
            success: function (res) {
                var ter = JSON.parse(res)
                console.log(ter.data)

                $(ter.data).each(function () {
                    $('#QualityNumber2').val(this.qualityNumber);
                    $('#QualityName2').val(this.qualityName);
                    $('#QualityTime2').val(this.qualityTime.substring(0, 10));
                    $('#Qualityer2').val(this.qualityer);
                    $('#Supplier2').val(this.supplier);
                    $('#MaterialNumber2').val(this.materialNumber);
                    $('#MaterialName2').val(this.materialName);
                    $('#Unit2').val(this.unit);
                    $('#SpecificationsModel2').val(this.specificationsModel);
                    $('#batchNumber2').val(this.batchNumber);
                    $('#Size2').val(this.size);
                    $('#ReinspectionNumber23').val(this.unqualifiedQuantity);
                    $('#ReInCode2').val(this.reinspectionCode);
                    $('#HeGeSarte2').val(this.heGeSarte);
                    $('#ReinspectionNote2').val(this.reinspectionNote);
                    $('#ReinspectionName2').val(this.reinspectionName);
                    $('#ReinspectionTime2').val(this.reinspectionTime.substring(0, 10));
                    $('#ReinspectionNumber2').val(this.reinspectionNumber);
                    $('#ReName2').val(this.reName);
                    localStorage.setItem("rawMaterialQualityId", this.rawMaterialQualityId)
                })

            },

        });


    }
    //修改复检信息
    var obj1 = {
        "createdBy": "",
        "createdDate": "",
        "updatedBy": "",
        "updatedDate": "",
        "deletedBy": "",
        "deletedDate": "",
        "isDeleted": false,
        "reinspectionId": "",
        "reinspectionCode": "",
        "reinspectionName": "",
        "reinspectionNumber": "",
        "reinspectionNote": "",
        "reinspectionSarte": "",
        "heGeSarte": "",
        "reinspectionTime": "",
        "reName": "",
        "rawMaterialQualityId": ""
    };
    layui.use(function () {
        var $ = layui.$;
        var layer = layui.layer;
        var util = layui.util;
        var form = layui.form;
        var table = layui.table;

        window.formSubmit = function formSubmit() {
            obj1.createdBy = ""
            obj1.createdDate = ""
            obj1.updatedBy = ""
            obj1.updatedDate = ""
            obj1.reinspectionId = localStorage.getItem("reinspectionId")
            obj1.reinspectionCode = $("#ReInCode2").val()
            obj1.reinspectionName = $("#ReinspectionName2").val()
            obj1.reinspectionNumber = $("#ReinspectionNumber2").val()
            obj1.reinspectionNote = $("#ReinspectionNote2").val()
            obj1.reinspectionSarte = "已复检"
            obj1.heGeSarte = $("[name='HeGeSarte2']:checked").val()
            obj1.reinspectionTime = $("#ReinspectionTime2").val()
            obj1.reName = $("#ReName2").val()
            obj1.rawMaterialQualityId = localStorage.getItem("rawMaterialQualityId")
            console.log(obj1)
            // 显示填写结果，仅作演示用
            $.ajax({
                url: '../Quality/UpdateRew',
                type: 'post',
                data: {
                    field: obj1,
                    token: localStorage.getItem("token"),
                },
                success: function (res) {
                    var res = JSON.parse(res)
                    console.log(obj1);
                    console.log(res);
                    if (res.code > 0) {
                        layer.alert("复检成功");
                        location.href = '/Quality/ReInfIndexShow'
                    } else {
                        layer.alert("复检失败");
                    }
                }
            });
        }
       

    });
   
})

